﻿using System;
using Microsoft.Xna.Framework.Graphics;

namespace Microsoft.Xna.Framework
{
	/// <summary>
	/// Holds the settings for creating a graphics device on Windows.
	/// </summary>
	public class GraphicsDeviceInformation
	{
		private GraphicsAdapter adapter;

		#region Properties
		/// <summary>
		/// Specifies which graphics adapter to create the device on.
		/// </summary>
		public GraphicsAdapter Adapter
		{
			get { return this.adapter; }
			set
			{
				if (this.adapter == null)
				{
					throw new ArgumentNullException("value", FrameworkResources.NoNullUseDefaultAdapter);
				}
				this.adapter = value;
			}
		}

		/// <summary>
		/// Gets the graphics profile, which determines the graphics feature set.
		/// </summary>
		public GraphicsProfile GraphicsProfile { get; set; }

		/// <summary>
		/// Specifies the presentation parameters to use when creating a graphics device.
		/// </summary>
		public PresentationParameters PresentationParameters { get; set; }
		#endregion

		#region Constructor
		/// <summary>
		/// Initializes a new instance of this class.
		/// </summary>
		public GraphicsDeviceInformation()
		{
			this.PresentationParameters = new PresentationParameters();
			this.adapter = GraphicsAdapter.DefaultAdapter;
		}
		#endregion

		#region Public Methods
		/// <summary>
		/// Creates a clone of this object.
		/// </summary>
		public GraphicsDeviceInformation Clone()
		{
			GraphicsDeviceInformation gdi = new GraphicsDeviceInformation();
			gdi.adapter = this.adapter;
			gdi.GraphicsProfile = this.GraphicsProfile;
			gdi.PresentationParameters = this.PresentationParameters.Clone();
			return gdi;
		}

		/// <summary>
		/// Returns a value that indicates whether the current instance is equal to a specified object.
		/// </summary>
		/// <param name="obj">The Object to compare with the current GraphicsDeviceInformation.</param>
		public override bool Equals(object obj)
		{
			GraphicsDeviceInformation information = obj as GraphicsDeviceInformation;
			if (information == null)
			{
				return false;
			}
			if (!information.adapter.Equals(this.adapter))
			{
				return false;
			}
			if (!information.GraphicsProfile.Equals(this.GraphicsProfile))
			{
				return false;
			}
			return ((((information.PresentationParameters.BackBufferWidth == this.PresentationParameters.BackBufferWidth) && (information.PresentationParameters.BackBufferHeight == this.PresentationParameters.BackBufferHeight)) && ((information.PresentationParameters.BackBufferFormat == this.PresentationParameters.BackBufferFormat) && (information.PresentationParameters.DepthStencilFormat == this.PresentationParameters.DepthStencilFormat))) && ((((information.PresentationParameters.MultiSampleCount == this.PresentationParameters.MultiSampleCount) && (information.PresentationParameters.DisplayOrientation == this.PresentationParameters.DisplayOrientation)) && ((information.PresentationParameters.PresentationInterval == this.PresentationParameters.PresentationInterval) && (information.PresentationParameters.RenderTargetUsage == this.PresentationParameters.RenderTargetUsage))) && (!(information.PresentationParameters.DeviceWindowHandle != this.PresentationParameters.DeviceWindowHandle) && (information.PresentationParameters.IsFullScreen == this.PresentationParameters.IsFullScreen))));
		}

		/// <summary>
		/// Gets the hash code for this object.
		/// </summary>
		public override int GetHashCode()
		{
			return (((((((((((this.GraphicsProfile.GetHashCode() ^ this.adapter.GetHashCode()) ^ this.PresentationParameters.BackBufferWidth.GetHashCode()) ^ this.PresentationParameters.BackBufferHeight.GetHashCode()) ^ this.PresentationParameters.BackBufferFormat.GetHashCode()) ^ this.PresentationParameters.DepthStencilFormat.GetHashCode()) ^ this.PresentationParameters.MultiSampleCount.GetHashCode()) ^ this.PresentationParameters.DisplayOrientation.GetHashCode()) ^ this.PresentationParameters.PresentationInterval.GetHashCode()) ^ this.PresentationParameters.RenderTargetUsage.GetHashCode()) ^ this.PresentationParameters.DeviceWindowHandle.GetHashCode()) ^ this.PresentationParameters.IsFullScreen.GetHashCode());
		}
		#endregion
	}
}
